package File;

import java.io.File;
import java.io.FilenameFilter;

//文件过滤器,Command设计模式
public class FilenameFilterTest {
    public static void main(String[] args) {
        File file = new File(".");
        String[] strings = file.list(new MyFilenameFilter());
        for (String name : strings) {
            System.out.println(name);
        }
    }
}
class MyFilenameFilter implements FilenameFilter {

    public boolean accept(File dir, String name) {
        return name.endsWith(".java") || new File(name).isDirectory();
    }
}
